#!/bin/sh
echo $0 $*

GAMEDIR=${PWD}
echo ==========GAMEDIR is $GAMEDIR
controlfolder="../PortMaster"

source $controlfolder/control.txt
#source $controlfolder/tasksetter

get_controls

# 增加错误输出记录
exec > >(tee "$GAMEDIR/log.txt") 2>&1

# 修改为直接获取文件夹名称的用法,不同游戏文件名不同
GAMEDIR="/mnt/SDCARD/Ports/cdogs"

cd $GAMEDIR

rm -rf ~/.config/cdogs-sdl
ln -sfv $GAMEDIR/conf/cdogs-sdl/ ~/.config/

cd $GAMEDIR/data

chmod 666 /dev/tty1
$ESUDO $controlfolder/oga_controls cdogs-sdl $param_device &
./cdogs-sdl 2>&1 | tee -a $GAMEDIR/log.txt
$ESUDO kill -9 $(pidof oga_controls)
$ESUDO systemctl restart oga_events &
printf "\033c" > /dev/tty1
